package fr.afcepf.ai85.gepeto.service;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import fr.afcepf.ai85.ent.Eleve;
import fr.afcepf.ai85.hibernate.util.HibernateUtil;


public class EleveHibernate {

	public static void main(String[] args) {
		
		
		Session session = HibernateUtil.currentSession();
		Transaction tx = session.beginTransaction();
		
//		Query sql2 = session.createSQLQuery(
//				"SELECT * FROM Type_connexion").
//					addEntity(Eleve.class);
//		List<TypeConnexion> liste2 = sql2.list();
//		for(TypeConnexion c : liste2){
//			System.out.println(c.getNomTypeConnexion());
//		}
//		
		
		
		
//		Query hql = session.createQuery("FROM Eleve");
//		List<Eleve> liste3 = hql.list();
//		for (Eleve el : liste3) {
//			System.out.println(el.getNomEnfant());
//		}
		
		
		Query hql2 = session.createQuery(
				"FROM Eleve el WHERE el.idEleve like :idel");
			hql2.setString("idel", "28");
			List<Eleve> liste4 = hql2.list();
			for (Eleve ee : liste4) {
				System.out.println(ee.getNomEnfant());
			}
		
		
		//tx.commit();
		HibernateUtil.closeSession();
	}
	
}
